package com.zengqingfa.designpattern.structure.flyweight;

/**
 * @author zengqingfa
 * @className Test
 * @description
 * @create 2021/8/29 15:29
 */
public class Test {

    public static void main(String[] args) {
        Integer i1 = 1; //自动装箱调用Integer.valueOf(1)
        Integer i2 = 1;
        System.out.println(i1 == i2);//true

        Integer j1 = 128;
        Integer j2 = 128;
        System.out.println(j1 == j2);//false



        // s1与s2的赋值皆为常量
        String s1 = "hello";
        String s2 = "hello";
        System.out.println(s1 == s2); //true

        // s3的赋值为常量，s4的赋值为常量加变量
        String s3 = "he" + "llo";
        String s4 = "he" + new String("llo");//false
        System.out.println(s3 == s4);

        // s5的赋值为变量，s6的赋值为intern()方法
        String s5 = new String("hello");
        String s6 = s5.intern();
        System.out.println(s5 == s6);//false

        // s1的赋值为常量，s6的赋值为intern()方法
        System.out.println(s1 == s6); //true
    }
}